home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drawgfx.h < prev    next >
C/C++ Source or Header  |  2000-05-18  |  6KB  |  143 lines

  1. /*********************************************************************
  2.  
  3.   drawgfx.h
  4.  
  5.   Generic graphic functions.
  6.  
  7. *********************************************************************/
  8.  
  9. #ifndef DRAWGFX_H
  10. #define DRAWGFX_H
  11.  
  12. #define MAX_GFX_PLANES 8
  13. #define MAX_GFX_SIZE 64
  14.  
  15. #define RGN_FRAC(num,den) (0x80000000 | (((num) & 0x0f) << 27) | (((den) & 0x0f) << 23))
  16. #define IS_FRAC(offset) ((offset) & 0x80000000)
  17. #define FRAC_NUM(offset) (((offset) >> 27) & 0x0f)
  18. #define FRAC_DEN(offset) (((offset) >> 23) & 0x0f)
  19. #define FRAC_OFFSET(offset) ((offset) & 0x007fffff)
  20.  
  21.  
  22. struct GfxLayout
  23. {
  24.     UINT16 width,height; /* width and height (in pixels) of chars/sprites */
  25.     UINT32 total; /* total numer of chars/sprites in the rom */
  26.     UINT16 planes; /* number of bitplanes */
  27.     UINT32 planeoffset[MAX_GFX_PLANES]; /* start of every bitplane (in bits) */
  28.     UINT32 xoffset[MAX_GFX_SIZE]; /* position of the bit corresponding to the pixel */
  29.     UINT32 yoffset[MAX_GFX_SIZE]; /* of the given coordinates */
  30.     UINT16 charincrement; /* distance between two consecutive characters/sprites (in bits) */
  31. };
  32.  
  33. struct GfxElement
  34. {
  35.     int width,height;
  36.  
  37.     unsigned int total_elements;    /* total number of characters/sprites */
  38.     int color_granularity;    /* number of colors for each color code */
  39.                             /* (for example, 4 for 2 bitplanes gfx) */
  40.     unsigned short *colortable;    /* map color codes to screen pens */
  41.                                 /* if this is 0, the function does a verbatim copy */
  42.     int total_colors;
  43.     unsigned int *pen_usage;    /* an array of total_elements ints. */
  44.                                 /* It is a table of the pens each character uses */
  45.                                 /* (bit 0 = pen 0, and so on). This is used by */
  46.                                 /* drawgfgx() to do optimizations like skipping */
  47.                                 /* drawing of a totally transparent characters */
  48.     unsigned char *gfxdata;    /* pixel data */
  49.     int line_modulo;    /* amount to add to get to the next line (usually = width) */
  50.     int char_modulo;    /* = line_modulo * height */
  51. };
  52.  
  53. struct GfxDecodeInfo
  54. {
  55.     int memory_region;    /* memory region where the data resides (usually 1) */
  56.                         /* -1 marks the end of the array */
  57.     int start;    /* beginning of data to decode */
  58.     struct GfxLayout *gfxlayout;
  59.     int color_codes_start;    /* offset in the color lookup table where color codes start */
  60.     int total_color_codes;    /* total number of color codes */
  61. };
  62.  
  63.  
  64. struct rectangle
  65. {
  66.     int min_x,max_x;
  67.     int min_y,max_y;
  68. };
  69.  
  70.  
  71. enum
  72. {
  73.     TRANSPARENCY_NONE,            /* opaque with remapping */
  74.     TRANSPARENCY_NONE_RAW,        /* opaque with no remapping */
  75.     TRANSPARENCY_PEN,            /* single pen transparency with remapping */
  76.     TRANSPARENCY_PEN_RAW,        /* single pen transparency with no remapping */
  77.     TRANSPARENCY_PENS,            /* multiple pen transparency with remapping */
  78.     TRANSPARENCY_PENS_RAW,        /* multiple pen transparency with no remapping */
  79.     TRANSPARENCY_COLOR,            /* single remapped pen transparency with remapping */
  80.     TRANSPARENCY_THROUGH,        /* destination pixel overdraw with remapping */
  81.     TRANSPARENCY_THROUGH_RAW,    /* destination pixel overdraw with no remapping */
  82.     TRANSPARENCY_PEN_TABLE,        /* special pen remapping modes (see DRAWMODE_xxx below) */
  83.     TRANSPARENCY_BLEND,            /* blend two bitmaps, shifting the source and ORing to the dest with remapping */
  84.     TRANSPARENCY_BLEND_RAW,        /* blend two bitmaps, shifting the source and ORing to the dest with no remapping */
  85.  
  86.     TRANSPARENCY_MODES            /* total number of modes; must be last */
  87. };
  88.  
  89. /* drawing mode case TRANSPARENCY_PEN_TABLE */
  90. extern UINT8 gfx_drawmode_table[256];
  91. enum
  92. {
  93.     DRAWMODE_NONE,
  94.     DRAWMODE_SOURCE,
  95.     DRAWMODE_SHADOW,
  96.     DRAWMODE_HIGHLIGHT
  97. };
  98.  
  99.  
  100. typedef void (*plot_pixel_proc)(struct osd_bitmap *bitmap,int x,int y,int pen);
  101. typedef int  (*read_pixel_proc)(struct osd_bitmap *bitmap,int x,int y);
  102.  
  103. /* pointers to pixel functions.  They're set based on orientation, depthness and weather
  104.    dirty rectangle handling is enabled */
  105. extern plot_pixel_proc plot_pixel;
  106. extern read_pixel_proc read_pixel;
  107.  
  108.  
  109. void decodechar(struct GfxElement *gfx,int num,const unsigned char *src,const struct GfxLayout *gl);
  110. struct GfxElement *decodegfx(const unsigned char *src,const struct GfxLayout *gl);
  111. void set_pixel_functions(void);
  112. void freegfx(struct GfxElement *gfx);
  113. void drawgfx(struct osd_bitmap *dest,const struct GfxElement *gfx,
  114.         unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
  115.         const struct rectangle *clip,int transparency,int transparent_color);
  116. void pdrawgfx(struct osd_bitmap *dest,const struct GfxElement *gfx,
  117.         unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
  118.         const struct rectangle *clip,int transparency,int transparent_color,
  119.         UINT32 priority_mask);
  120. void copybitmap(struct osd_bitmap *dest,struct osd_bitmap *src,int flipx,int flipy,int sx,int sy,
  121.         const struct rectangle *clip,int transparency,int transparent_color);
  122. void copybitmap_remap(struct osd_bitmap *dest,struct osd_bitmap *src,int flipx,int flipy,int sx,int sy,
  123.         const struct rectangle *clip,int transparency,int transparent_color);
  124. void copybitmapzoom(struct osd_bitmap *dest,struct osd_bitmap *src,int flipx,int flipy,int sx,int sy,
  125.         const struct rectangle *clip,int transparency,int transparent_color,int scalex,int scaley);
  126. void copyscrollbitmap(struct osd_bitmap *dest,struct osd_bitmap *src,
  127.         int rows,const int *rowscroll,int cols,const int *colscroll,
  128.         const struct rectangle *clip,int transparency,int transparent_color);
  129. void copyscrollbitmap_remap(struct osd_bitmap *dest,struct osd_bitmap *src,
  130.         int rows,const int *rowscroll,int cols,const int *colscroll,
  131.         const struct rectangle *clip,int transparency,int transparent_color);
  132. void fillbitmap(struct osd_bitmap *dest,int pen,const struct rectangle *clip);
  133. void plot_pixel2(struct osd_bitmap *bitmap1,struct osd_bitmap *bitmap2,int x,int y,int pen);
  134. void drawgfxzoom( struct osd_bitmap *dest_bmp,const struct GfxElement *gfx,
  135.         unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
  136.         const struct rectangle *clip,int transparency,int transparent_color,int scalex,int scaley);
  137. void pdrawgfxzoom( struct osd_bitmap *dest_bmp,const struct GfxElement *gfx,
  138.         unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
  139.         const struct rectangle *clip,int transparency,int transparent_color,int scalex,int scaley,
  140.         UINT32 priority_mask);
  141.  
  142. #endif
  143.